import My from './view/My.vue'
import Loginin from './page/login/Loginin.vue'
import Register from './page/login/Register.vue'
import Forget from './page/login/Forget.vue'
import FloatingWindow from './view/FloatingWindow'
import Sidebar from './view/Sidebar'
import Overview from './view/Overview.vue'
import Methods from './view/Methods.vue'
import Strategy from './view/Strategy.vue'
import Features from './view/Features.vue'
import RecTechnology from './view/RecTechnology.vue'

import yuntu from './view/product/1_0Monitor/2_0yuntu.vue'
import radarPic from './view/product/1_0Monitor/1_0radarPic.vue'
import floodMonitor from './view/product/1_0Monitor/3_0floodMonitor.vue'
import subsidenceMonitor from './view/product/1_0Monitor/4_0subsidenceMonitor.vue'

import qpe from './view/product/2_0Identify/1_0qpe.vue'
import qpegl from './view/product/2_0Identify/2_0qpegl.vue'
import recognition from './view/product/2_0Identify/3_0recognition.vue'

import typhoonPredict from './view/product/2_1Identify/1_0typhoonPredict.vue'
import yuntuRecognition from './view/product/2_1Identify/2_0yuntuRecognition.vue'

import dbz from './view/product/3_0Forewarn/1_0dbz.vue'
import rainfall from './view/product/3_0Forewarn/2_0rainfall.vue'
import qpfgl from './view/product/3_0Forewarn/3_0qpfgl.vue'
import forecast from './view/product/3_0Forewarn/4_0forecast.vue'
import convectivegust from './view/product/3_0Forewarn/5_0convectivegust.vue'
import strongrain from './view/product/3_0Forewarn/6_0strongrain.vue'
import wind from './view/product/3_0Forewarn/7_0wind.vue'
import typhoon from './view/product/3_0Forewarn/8_0typhoon.vue'

import floodForecast from './view/product/3_1Forewarn/1_0floodForecast.vue'
import storm from './view/product/3_1Forewarn/2_0storm.vue'
import hoursmax from './view/product/3_1Forewarn/3_0hoursmax.vue'
import waterlogging from './view/product/3_1Forewarn/4_0waterlogging.vue'
import GBA from './view/product/3_1Forewarn/5_0GBA.vue'
import SZ from './view/product/3_1Forewarn/6_0SZ.vue'

import FQYJ from './view/product/4_0FQYJ/1_0FQYJ.vue'
import BXFB from './view/product/5_0BXFB/1_0BXFB.vue'

import { createRouter, createWebHashHistory } from 'vue-router';
import store from "@/store";


const routes = [
  {
    path: '/my',
    name: 'my',
    component: My
  },
  {
    path: '/',
    name: 'login',
    component: Loginin,
  },
  {
    path: '/register',
    name: 'register',
    component: Register
  },
  {
    path: '/forget',
    name: 'forget',
    component: Forget
  },
  {
    path: '/Sidebar',
    name: 'Sidebar',
    component: Sidebar
  },
  {
    path: '/FloatingWindow',
    name: 'FloatingWindow',
    component: FloatingWindow
  },
  {
    path: '/yuntu',
    name: 'yuntu',
    component: yuntu,
    meta: { menuIndex: 0, selectProduct: "0_0" }

  },
  {
    path: '/radarPic',
    name: 'radarPic',
    component: radarPic,
    meta: { menuIndex: 0, selectProduct: "0_1" }

  },
  {
    path: '/floodMonitor',
    name: 'floodMonitor',
    component: floodMonitor,
    meta: { menuIndex: 1, selectProduct: "0_0" }

  },
  {
    path: '/subsidenceMonitor',
    name: 'subsidenceMonitor',
    component: subsidenceMonitor,
    meta: { menuIndex: 1, selectProduct: "0_1" }

  },
  {
    path: '/qpe',
    name: 'qpe',
    component: qpe,
    meta: { menuIndex: 2, selectProduct: "0_0" }

  },

  {
    path: '/qpegl',
    name: 'qpegl',
    component: qpegl,
    meta: { menuIndex: 2, selectProduct: "0_1" }

  },
  {
    path: '/recognition',
    name: 'recognition',
    component: recognition,
    meta: { menuIndex: 2, selectProduct: "0_2" }

  },
  {
    path: "/typhoonPredict",
    name: "typhoonPredict",
    component: typhoonPredict,
    meta: { menuIndex: 2, selectProduct: "1_0" }
  },
  {
    path: "/yuntuRecognition",
    name: "yuntuRecognition",
    component: yuntuRecognition,
    meta: { menuIndex: 2, selectProduct: "1_1" }
  },
  {
    path: '/FQYJ',
    name: 'FQYJ',
    component: FQYJ,
    meta: { menuIndex: 4, selectProduct: "0_0" }
  },
  {
    path: '/BXFB',
    name: 'BXFB',
    component: BXFB,
    meta: { menuIndex: 5, selectProduct: "0_0" }
  },
  {
    path: '/dbz',
    name: 'dbz',
    component: dbz,
    meta: { menuIndex: 3, selectProduct: "0_0" }

  },
  {
    path: '/rainfall',
    name: 'rainfall',
    component: rainfall,
    meta: { menuIndex: 3, selectProduct: "0_1" }

  },
  {
    path: '/qpfgl',
    name: 'qpfgl',
    component: qpfgl,
    meta: { menuIndex: 3, selectProduct: "0_2" }

  },
  {
    path: '/forecast',
    name: 'forecast',
    component: forecast,
    meta: { menuIndex: 3, selectProduct: "0_3" }

  },

  {
    path: '/convectivegust',
    name: 'convectivegust',
    component: convectivegust,
    meta: { menuIndex: 3, selectProduct: "0_4" }

  },
  {
    path: '/strongrain',
    name: 'strongrain',
    component: strongrain,
    meta: { menuIndex: 3, selectProduct: "0_5" }
  },
  {
    path: '/wind',
    name: 'wind',
    component: wind,
    meta: { menuIndex: 3, selectProduct: "0_6" }
  },
  {
    path: '/typhoon',
    name: 'typhoon',
    component: typhoon,
    meta: { menuIndex: 3, selectProduct: "0_7" }
  },
  {
    path: '/floodForecast',
    name: 'floodForecast',
    component: floodForecast,
    meta: { menuIndex: 3, selectProduct: "1_0" }
  },
  {
    path: '/storm',
    name: 'storm',
    component: storm,
    meta: { menuIndex: 3, selectProduct: "1_1" }
  },
  {
    path: '/hoursmax',
    name: 'hoursmax',
    component: hoursmax,
    meta: { menuIndex: 3, selectProduct: "1_2" }
  },

  {
    path: '/waterlogging',
    name: 'waterlogging',
    component: waterlogging,
    meta: { menuIndex: 3, selectProduct: "1_3" }
  },

  {
    path: '/GBA',
    name: 'GBA',
    component: GBA,
    meta: { menuIndex: 3, selectProduct: "1_4" }
  },

  {
    path: '/SZ',
    name: 'SZ',
    component: SZ,
    meta: { menuIndex: 3, selectProduct: "1_5" }
  },

  {
    path: '/Overview',
    name: 'Overview',
    component: Overview,
    meta: { menuIndex: 8, selectProduct: "0_0" }
  },

  {
    path: '/Strategy',
    name: 'Strategy',
    component: Strategy,
    meta: { menuIndex: 7, selectProduct: "0_0" }
  },

  {
    path: '/Methods',
    name: 'Methods',
    component: Methods,
    meta: { menuIndex: 7, selectProduct: "0_1" }
  },

  {
    path: '/RecTechnology',
    name: 'RecTechnology',
    component: RecTechnology,
    meta: { menuIndex: 6, selectProduct: "0_0" }
  },

  {
    path: '/Features',
    name: 'Features',
    component: Features,
    meta: { menuIndex: 6, selectProduct: "0_1" }
  },

]

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes
});

const whiteList = ['login', 'register', 'forget', 'qpe', 'FloatingWindow', 'test', 'Sidebar', 'Rainfall', 'Radar', 'Rectangle', 'yuntu', 'radarPic', 'convectivegust', 'strongrain', 'Recognition', "typhoonPredict", "yuntuRecognition"]

router.beforeEach((to, from, next) => {
  let isLogin = store.state.isLogin
  //  如果用户匿名状态下访问非白名单页面，跳转到登录页面
  if (!whiteList.includes(to.name) && !isLogin) {
    next({ path: '/' })
  } else {
    next()
  }
})


export default router
